/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bl;

import java.awt.Graphics2D;
import java.util.LinkedList;

/**
 *
 * @author Alexander_Seiner
 */
public class GalaxyArm extends BasicGraphicElement
{
    private int startAngle;
    private int armRotation;
    private GalaxyArmPoint[] armPoints;
    
    public GalaxyArm(float posX, float posY, float width, float height, LinkedList<BasicGraphicElement> childElements, int startAngle, int armRotation) {
        super(posX, posY, width, height, childElements);
        this.startAngle = startAngle;
        this.armRotation = armRotation;
        
        
        armPoints = new GalaxyArmPoint[50];
        int currAngle = startAngle+45;
        for(int i = 0; i < armPoints.length; i++)
        {
            armPoints[i] = new GalaxyArmPoint((int)(this.getPosX()+Math.cos(Math.toRadians(currAngle))*100*i/10), (int)(this.getPosY()-Math.sin(Math.toRadians(currAngle))*100*i/20));
            currAngle += armRotation;
        }
    }

    public int getStartAngle() {
        return startAngle;
    }

    public void setStartAngle(int startAngle) {
        this.startAngle = startAngle;
    }

    @Override
    public void draw(Graphics2D g2d) 
    {
        g2d.fillRect((int)this.getPosX()-2, (int)this.getPosY()-2, 4, 4);
        
        
        
        for(int i = 1; i <= armPoints.length; i++)
        {
            g2d.fillRect((int)armPoints[i-1].getPosX(), (int)(int)armPoints[i-1].getPosY(), 1, 1);
        }
        
        if(this.getChildElements() != null && !this.getChildElements().isEmpty())
        {
            for(BasicGraphicElement bge : this.getChildElements())
            {
                bge.draw(g2d);
            }
        }
    }
}
